import request from '@/utils/request'
import type { Goods } from '@/types/goods';

// 查询商品列表
export function listGoods(query) {
  return request<Goods[], ResponseListData<Goods>>({
    url: '/merchant/goods/list',
    method: 'GET',
    params: query
  })
}

// 查询商品详细
export function getGoods(id: number) {
  return request<Goods, ResponseData<Goods>>({
    url: '/merchant/goods/' + id,
    method: 'GET'
  })
}

// 新增商品
export function addGoods(data) {
  return request<Goods, ResponseData<Goods>>({
    url: '/merchant/goods',
    method: 'POST',
    data: data
  })
}

// 修改商品
export function updateGoods(data) {
  return request<Goods, ResponseData<Goods>>({
    url: '/merchant/goods',
    method: 'PUT',
    data: data
  })
}

// 删除商品
export function delGoods(id) {
  return request<Goods, ResponseData<Goods>>({
    url: '/merchant/goods/' + id,
    method: 'DELETE'
  })
}
